#include <stdio.h>

struct peolpe {
	int rank;
	int num;
	int index;
} a[100], temp;

int main(void) {

	int T = 0;
	scanf("%d", &T);
	for (int i = 0; i < T; i++) {

		int n = 0;
		scanf("%d", &n);
		for (int j = 0; j < n; j++) {
			scanf("%d", &a[j].num);
			a[j].index = j + 1;
		}
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[j].num > a[i].num || a[j].num == a[i].num && a[j].index < a[i].index) {
					temp = a[j];
					a[j] = a[i];
					a[i] = temp;
				}
			}
		}
		a[0].rank = 1;
		for (int i = 1; i < n; i++) {
			if (a[i].num == a[i - 1].num)
				a[i].rank = a[i - 1].rank;
			else
				a[i].rank = i + 1;
		}
		for (int i = 0; i < n; i++)
			printf("%d %d %d\n", a[i].rank, a[i].num, a[i].index);
		if (i != T)
			printf("\n");
	}
}

